package com.project.app.server.companise;

import com.project.common.annotation.Log;
import com.project.common.core.controller.BaseController;
import com.project.common.core.domain.AjaxResult;
import com.project.common.enums.BusinessType;
import com.project.server.domain.companies.TCompanyStaff;
import com.project.server.service.companies.ITCompanyStaffService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 小程序企业员工信息
 */
@RestController
@RequestMapping("/app/server/staff")
public class ATCompanyStaffController extends BaseController {

    @Resource
    private ITCompanyStaffService tCompanyStaffService;

    /**
     * 根据员工电话号码获取详细信息
     */
    @GetMapping(value = "/{openId}")
    public AjaxResult getByOpenId(@PathVariable String openId) {
        return AjaxResult.success(tCompanyStaffService.selectTCompanyStaffByOpenId(openId));
    }

//    /**
//     * 根据员工电话号码获取详细信息
//     */
//    //@PreAuthorize("@ss.hasPermi('server:staff:query')")
//    @GetMapping(value = "/{staffPhone}")
//    public AjaxResult getByPhone(@PathVariable String staffPhone) {
//        return AjaxResult.success(tCompanyStaffService.selectTCompanyStaffByStaffPhone(staffPhone));
//    }

    /**
     * 修改员工信息
     */
    @Log(title = "员工信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody TCompanyStaff tCompanyStaff) {
        return toAjax(tCompanyStaffService.updateTCompanyStaff(tCompanyStaff));
    }
}
